package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 申请任务时间表
 */
@Entity
@Table(name = "ccd_apply_worktime")
@JsonApiResource(type = "applyWorktime")
public class ApplyWorktime extends BaseEntity {
	private String code;//32位字符串
	private UserTask userTask;//用户任务
	private Worktime worktime;//工作时间
	private Short signStatus;//签到情况 1已签到 0未签到
	private Short runStatus;//运行状态 0 未运行  1 进行中
	private String remark;//备注

	@Column(name = "code")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "user_task_id",foreignKey = @ForeignKey(name = "null"))
	public UserTask getUserTask() {
		return userTask;
	}

	public void setUserTask(UserTask userTask) {
		this.userTask = userTask;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "worktime_id",foreignKey = @ForeignKey(name = "null"))
	public Worktime getWorktime() {
		return worktime;
	}

	public void setWorktime(Worktime worktime) {
		this.worktime = worktime;
	}

	@Column(name = "sign_status")
	public Short getSignStatus() {
		return signStatus;
	}

	public void setSignStatus(Short signStatus) {
		this.signStatus = signStatus;
	}

	@Column(name = "run_status")
	public Short getRunStatus() {
		return runStatus;
	}

	public void setRunStatus(Short runStatus) {
		this.runStatus = runStatus;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}